package com.my.code.map;

public class TestOr {
    public static void main1(String[] args) {
        int[] arr = {1, 2, 3, 4, 10, 10, 10, 1, 2, 3, 4, 5, 6};
        int i = find(arr);
        System.out.println("i = " + i);
    }

    public static void main(String[] args) {
        int i = and(3);
        System.out.println("i = " + i);
    }

    static int find(int[] arr) {
        int tmp = arr[0];
        for (int i = 1; i < arr.length; i++) {
            tmp = tmp ^ arr[i];
        }
        return tmp;
    }

    static int pow(int n) {
        int sum = 1;
        int tmp = 3;
        while (n != 0) {
            if ((n & 1) == 1) {
                sum *= tmp;
            }
            tmp *= tmp;
            n = n >> 1;
        }
        return sum;
    }

    static int and(int n) {
        return n & (n - 1);
    }
}
